home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 2 (DVD) / XENIADVD2.iso / Patch / Project Nomads / pnomads_patch2_eng.exe / MAINDIR / Run / scripts / scriptlib.tcl < prev   
Encoding:
Text File  |  2002-09-11  |  46.9 KB  |  1,435 lines

  1. #-------------------------------------------------------------------------------
  2. #   scriptlib.tcl
  3. #   =============
  4. #   Implement the command set for the story scripting.
  5. #
  6. #   (C) 2001,2002 RadonLabs GmbH
  7. #-------------------------------------------------------------------------------
  8.  
  9. #-------------------------------------------------------------------------------
  10. #   Global variables
  11. #-------------------------------------------------------------------------------
  12. set curBook ""
  13. set curBookDir ""
  14.  
  15. set curChapter ""
  16. set curChapterDir ""
  17.  
  18. set curPart ""
  19. set curPartDir ""
  20.  
  21. #-------------------------------------------------------------------------------
  22. #   on_bookfinished
  23. #   
  24. #   This procedure is called by the book handler when the last part
  25. #   has been finished.
  26. #
  27. #   This procedure call the nm_reallykillgame procedure defined in
  28. #   newmenu.tcl.
  29. #-------------------------------------------------------------------------------
  30. proc on_bookfinished {} {
  31.     nm_thanxforplaying
  32. }
  33.  
  34. #-------------------------------------------------------------------------------
  35. #   book [body]
  36. #
  37. #   Define a book. Inside the book only 'loadchapter' statements should
  38. #   appear.
  39. #-------------------------------------------------------------------------------
  40. proc book {body} {
  41. global curBook
  42. global curBookDir
  43.     set curBookDir [/sys/servers/file.manglepath "book:"]
  44.     eval $body
  45. }
  46.  
  47. #-------------------------------------------------------------------------------
  48. #   loadchapter [dirname]
  49. #
  50. #   This takes the name of a subdirectory and simply sources
  51. #   the story.tcl file in this directory. This story.tcl file should
  52. #   contain a single 'chapter' statement.
  53. #-------------------------------------------------------------------------------
  54. proc loadchapter {dirname} {
  55. global curBookDir
  56. global curChapterDir
  57.  
  58. #    puts "-> loadchapter $dirname"
  59.  
  60.     set curChapterDir ""
  61.     append curChapterDir "$curBookDir" "$dirname"
  62.  
  63.     set cwd [pwd]
  64.     set dir [/sys/servers/file.manglepath $curChapterDir]
  65.     cd $dir
  66.     source story.tcl
  67.     cd $cwd
  68.  
  69. #    puts "<- loadchapter"
  70. }
  71.  
  72. #-------------------------------------------------------------------------------
  73. #   loadpart [dirname]
  74. #
  75. #   This takes the name of a subdirectory and simply source the
  76. #   story.tcl file in this directory. This story.tcl file should
  77. #   contain a single 'part' statement.
  78. #-------------------------------------------------------------------------------
  79. proc loadpart {dirname} {
  80. global curChapterDir
  81. global curPartDir
  82.  
  83. #    puts "-> loadpart $dirname"
  84.  
  85.     set curPartDir ""
  86.     append curPartDir "$curChapterDir" "/" "$dirname"
  87.     
  88.     set cwd [pwd]
  89.     set dir [/sys/servers/file.manglepath $curPartDir]
  90.     cd $dir
  91.     source story.tcl
  92.     cd $cwd
  93.  
  94. #    puts "<- loadpart"
  95. }
  96.  
  97. #-------------------------------------------------------------------------------
  98. #   chapter [name] [body]
  99. #
  100. #   Define a chapter. A chapter should consist of only 'loadpart' statements.
  101. #-------------------------------------------------------------------------------
  102. proc chapter {name body} {
  103. global curChapter
  104.  
  105. #    puts "-> chapter $name"
  106.  
  107.     # set global chapter variable and just execute the body
  108.     # which will actually call several 'loadpart' statements
  109.     set curChapter $name
  110.     eval $body
  111.  
  112. #    puts "<- chapter"
  113. }
  114.     
  115. #-------------------------------------------------------------------------------
  116. #   part [name] [body]
  117. #
  118. #   Define a part with its activation Tcl code. The body should only
  119. #   contain event handlers ('on' statements).
  120. #-------------------------------------------------------------------------------
  121. proc part {name body} {
  122. global curChapter
  123. global curPart
  124. global curPartDir
  125.  
  126. #    puts "-> part $name"
  127.  
  128.     set curPart $name
  129.  
  130.     # build a unique part name from the chapter name and the part
  131.     # name and register the part handler code with the book handler
  132.     set partName ""
  133.     append partName "$curChapter" "_" "$curPart"
  134.     /game/handler/book.registerpart $partName $curPartDir $body
  135.  
  136. #    puts "<- part"
  137. }
  138.  
  139. #-------------------------------------------------------------------------------
  140. #   on [event0] [and|or] [event1] [body]
  141. #
  142. #   Define an event handler for one or two events. The body is executed
  143. #   when the one or two events are triggered (in the case of two events,
  144. #   they can be "and" or "or" connected).
  145. #
  146. #   Implementation details:
  147. #   The procedure will create a Tcl procedure called "event_handler_$uniqueId"
  148. #   which is registered with the global nEventHandler object. The event handler
  149. #   will be called when the events are triggered by the event handler.
  150. #
  151. #-------------------------------------------------------------------------------
  152. proc on {args} {
  153.  
  154. #    puts "-> on $args"
  155.     
  156.     # num args can either be 3 or 6 (depends whether one or 2 events are given)
  157.     if {[llength $args] == 2} {
  158.  
  159.         set event0 [lindex $args 0]
  160.         set body [lindex $args 1]
  161.  
  162.         # add the event handler
  163.         /game/handler/event.addhandler $body $event0
  164.  
  165.     } elseif {[llength $args] == 4} {
  166.  
  167.         set event0 [lindex $args 0]
  168.         set opcode [lindex $args 1]
  169.         set event1 [lindex $args 2]
  170.         set body   [lindex $args 3]
  171.  
  172.         # add the event handler
  173.         /game/handler/event.addhandler2 $body $event0 $opcode $event1 
  174.  
  175.     } else {
  176.         # syntax error
  177.         puts "WRONG NUMBER OF ARGS IN PROC 'on $args'"
  178.         exit
  179.     }
  180.  
  181. #    puts "<- args"
  182. }
  183.  
  184. #-------------------------------------------------------------------------------
  185. #   loadencounter [filename] [as symbolicName] [pos x y z]
  186. #
  187. #   Loads an encounter inside a part, optionally gives it a symbolic name
  188. #   for later reference and places it at a position. The actual filename of the
  189. #   encounter is generated as follos:
  190. #
  191. #   $currentPartDir/encounters/$filename
  192. #
  193. #   The current part dir is requested from the book hander
  194. #-------------------------------------------------------------------------------
  195. proc loadencounter {filename args} {
  196.  
  197. #    puts "-> loadencounter $filename $args"
  198.  
  199.     # extract optional data
  200.     set numArgs [llength $args]
  201.     set symbolicName ""
  202.     set hasPos 0
  203.     set xPos 0
  204.     set yPos 0
  205.     set zPos 0
  206.     if {$numArgs > 0} {
  207.  
  208.         for {set curArg 0} {$curArg < $numArgs} {incr curArg} {
  209.             if {[lindex $curArg] == "as"} {
  210.                 incr curArg           
  211.                 set symbolicName [lindex $args $curArg]
  212.             } elseif {[lindex $curArg] == "pos"} {
  213.                 set hasPos 1
  214.                 incr curArg
  215.                 set xPos [lindex $args $curArg]
  216.                 incr curArg
  217.                 set yPos [lindex $args $curArg]
  218.                 incr curArg
  219.                 set zPos [lindex $args $curArg]
  220.             }
  221.         }
  222.     }
  223.  
  224.     # get the full filename for the encounter file
  225.     set partDir [/game/handler/book.getcurrentpartdir]
  226.  
  227.     # All cinematic are placed here
  228.     if {[exists /game/cinematics] == 0} {
  229.     new nroot /game/cinematics
  230.     }
  231.  
  232.     # Load cinematic sequences for encounter if any exist
  233.     set cinematicFile ""
  234.     append cinematicFile "$partDir" "/cinematics/" "$filename"
  235.     if {[file exists $cinematicFile] == 1} {
  236.         source $cinematicFile
  237.     }
  238.  
  239.     # load the encounter
  240.     set encounterFile ""
  241.     append encounterFile "$partDir" "/encounters/" "$filename"
  242.     set clan [/world.loadencounter $encounterFile]
  243.  
  244.     # optionally position it
  245.     if {$hasPos} {
  246.         $clan.setposition $xPos $yPos $zPos
  247.     }
  248.  
  249.     # optionally set symbolic name
  250.     if {$symbolicName != ""} {
  251.         $clan.setrealname $symbolicName
  252.     }
  253.  
  254. #    puts "<- loadencounter"
  255. }
  256.  
  257. #-------------------------------------------------------------------------------
  258. #   finishpart
  259. #
  260. #   Finish the current part and activate the next part. Slowly fade out audio
  261. #-------------------------------------------------------------------------------
  262. proc finishpart {} {
  263.     oneshottimer 3 _partfinished
  264.     /sys/servers/audio.flushaudio 3 3    
  265.     newv chptr_fadeout
  266. }
  267.  
  268. #-------------------------------------------------------------------------------
  269. #   startpart
  270. #
  271. #   Start with fadein.
  272. #-------------------------------------------------------------------------------
  273.  
  274. proc startpart {} {    
  275.     newv chptr_fadein
  276. }
  277.  
  278. #-------------------------------------------------------------------------------
  279. #   timer seconds event [as symbolicName]
  280. #
  281. #   Creates an infinite timer which throws an event every number
  282. #   of seconds.
  283. #   Please make sure the the environment setting is already loaded
  284. #   before creating any timers because all timer objects are created
  285. #   in the environment clan!!!
  286. #-------------------------------------------------------------------------------
  287. proc timer {seconds event args} {
  288.  
  289.     # get the environemt clan
  290.     set clan [/world.getenvironmentclan]
  291.     if {"null" == $clan} {
  292.         # makes no sense without env clan
  293.         return
  294.     }
  295.  
  296.     # parse optional args
  297.     set numArgs [llength $args]
  298.     set symbolicName ""
  299.     if {$numArgs > 0} {
  300.         for {set curArg 0} {$curArg < $numArgs} {incr curArg} {
  301.             if {[lindex $args $curArg] == "as"} {
  302.                 incr curArg    
  303.                 set symbolicName [lindex $args $curArg]
  304.             }
  305.         }
  306.     }
  307.  
  308.     # create a t_timer object
  309.     set t [$clan.createvehicle t_timer]
  310.     $t.setthrowevents true
  311.     $t.seteventslot timer "$event"
  312.     $t.setnumcycles 0
  313.     $t.setcycletime $seconds
  314.     if {$symbolicName != ""} {
  315.         $t.setsymbolicname $symbolicName
  316.     }
  317. }
  318.  
  319. #-------------------------------------------------------------------------------
  320. #   oneshottimer seconds event [as symbolicName]
  321. #
  322. #   Creates an oneshot timer which throws exactly one event and
  323. #   then self-destructs.
  324. #   Please make sure the the environment setting is already loaded
  325. #   before creating any timers because all timer objects are created
  326. #   in the environment clan!!!
  327. #-------------------------------------------------------------------------------
  328. proc oneshottimer {seconds event args} {
  329.     
  330.     # get the environemt clan
  331.     set clan [/world.getenvironmentclan]
  332.     if {"null" == $clan} {
  333.         # makes no sense without env clan
  334.         return
  335.     }
  336.  
  337.     # parse optional args
  338.     set numArgs [llength $args]
  339.     set symbolicName ""
  340.     if {$numArgs > 0} {
  341.         for {set curArg 0} {$curArg < $numArgs} {incr curArg} {
  342.             if {[lindex $args $curArg] == "as"} {
  343.                 incr curArg           
  344.                 set symbolicName [lindex $args $curArg]
  345.             }
  346.         }
  347.     }
  348.  
  349.     # create a t_timer object
  350.     set t [$clan.createvehicle t_timer]
  351.     $t.setthrowevents true
  352.     $t.seteventslot timer "$event"
  353.     $t.setnumcycles 1
  354.     $t.setcycletime $seconds
  355.     if {$symbolicName != ""} {
  356.         $t.setsymbolicname $symbolicName
  357.     }
  358. }
  359.  
  360. #-------------------------------------------------------------------------------
  361. #   oneshotaction seconds action
  362. #
  363. #   analog onmeshot-timer, aber mit aktion (script)
  364. #-------------------------------------------------------------------------------
  365. proc oneshotaction {seconds action} {
  366.     
  367.     # get the environemt clan
  368.     set clan [/world.getenvironmentclan]
  369.  
  370.     if {$clan != "null"} {
  371.         # create a t_timer object
  372.         set t [$clan.createvehicle t_timer]
  373.         $t.setthrowevents true
  374.         $t.setaction "$action"
  375.         $t.setnumcycles 1
  376.         $t.setcycletime $seconds
  377.     }
  378. }
  379.  
  380. #-------------------------------------------------------------------------------
  381. #   looptimer numloops seconds event [as symbolicName]
  382. #
  383. #   Creates an loop timer which throws exactly $numloop events and
  384. #   then self-destructs.
  385. #   Please make sure the the environment setting is already loaded
  386. #   before creating any timers because all timer objects are created
  387. #   in the environment clan!!!
  388. #-------------------------------------------------------------------------------
  389. proc looptimer {numloops seconds event args} {
  390.     
  391.     # get the environemt clan
  392.     set clan [/world.getenvironmentclan]
  393.     if {"null" == $clan} {
  394.         # makes no sense without env clan
  395.         return
  396.     }
  397.  
  398.     # parse optional args
  399.     set numArgs [llength $args]
  400.     set symbolicName ""
  401.     if {$numArgs > 0} {
  402.         for {set curArg 0} {$curArg < $numArgs} {incr curArg} {
  403.             if {[lindex $args $curArg] == "as"} {
  404.                 incr curArg           
  405.                 set symbolicName [lindex $args $curArg]
  406.             }
  407.         }
  408.     }
  409.  
  410.     # create a t_timer object
  411.     set t [$clan.createvehicle t_timer]
  412.     $t.setthrowevents true
  413.     $t.seteventslot timer "$event"
  414.     $t.setnumcycles $numloops
  415.     $t.setcycletime $seconds
  416.     if {$symbolicName != ""} {
  417.         $t.setsymbolicname $symbolicName
  418.     }
  419. }
  420.  
  421. #-------------------------------------------------------------------------------
  422. #   activate symbolicName
  423. #
  424. #   Invoke ".setthrowevents true" on all objects with a matching symbolic
  425. #   name.
  426. #-------------------------------------------------------------------------------
  427. proc activate {symbolicName} {
  428.  
  429.     puts "-> activate $symbolicName"
  430.  
  431.     set curObj ""
  432.     for {set curObj [/world.findobjectbysymbolicname $symbolicName]}\
  433.         {$curObj != "null"}\
  434.         {set curObj [/world.findnextobjectbysymbolicname $curObj $symbolicName]}\
  435.     {
  436.         $curObj.setthrowevents true
  437.     }
  438.  
  439.     puts "-> activate $symbolicName"
  440. }
  441.  
  442. #-------------------------------------------------------------------------------
  443. #   deactivate symbolicName
  444. #
  445. #   Invoke ".setthrowevents false" on all objects with a matching symbolic
  446. #   name.
  447. #-------------------------------------------------------------------------------
  448. proc deactivate {symbolicName} {
  449.  
  450.     puts "-> deactivate $symbolicName"
  451.  
  452.     set curObj ""
  453.     for {set curObj [/world.findobjectbysymbolicname $symbolicName]}\
  454.         {$curObj != "null"}\
  455.         {set curObj [/world.findnextobjectbysymbolicname $curObj $symbolicName]}\
  456.     {
  457.         $curObj.setthrowevents false
  458.     }
  459.  
  460.     puts "-> deactivate $symbolicName"
  461. }
  462.  
  463. #-------------------------------------------------------------------------------
  464. #   setfaction symbolicName [player | enemy1 | enemy2 | enemy3 | enemy4]
  465. #
  466. #   Set faction of all clans which match the symbolicName
  467. #-------------------------------------------------------------------------------
  468. proc setfaction {symbolicName faction} {
  469.  
  470.     # convert faction string into number
  471.     set factionId 0
  472.     if {$faction == "player"} {
  473.         set factionId 0
  474.     } elseif {$faction == "enemy1"} {
  475.         set factionId 1
  476.     } elseif {$faction == "enemy2"} {
  477.         set factionId 2
  478.     } elseif {$faction == "enemy3"} {
  479.         set factionId 3
  480.     } elseif {$faction == "enemy4"} {
  481.         set factionId 4
  482.     } else {
  483.         # undefined factionId, set to 128 for now
  484.         set factionId 128
  485.     }
  486.  
  487.     set curClan ""
  488.     for {set curClan [/world.findclanbysymbolicname $symbolicName]}\
  489.         {$curClan != "null"}\
  490.         {set curClan [/world.findnextclanbysymbolicname $curClan $symbolicName]}\
  491.     {
  492.         puts "$curClan.setfaction $factionId"
  493.         $curClan.setfaction $factionId
  494.     }
  495. }
  496.  
  497. #-------------------------------------------------------------------------------
  498. #   putevent event
  499. #
  500. #   Manually throw an event.
  501. #-------------------------------------------------------------------------------
  502. proc putevent {event} {
  503.     /game/handler/event.putevent $event
  504. }
  505.  
  506. #-------------------------------------------------------------------------------
  507. #   daytime hours minutes
  508. #
  509. #   Set the game's time of day.
  510. #-------------------------------------------------------------------------------
  511. proc daytime {hours mins} {
  512.  
  513.     set seconds [expr ($hours * 3600) + ($mins * 60)]
  514.     /world.settimeofday $seconds
  515. }
  516.  
  517. #-------------------------------------------------------------------------------
  518. #   resetplayerat
  519. #
  520. #   Reset the player's island to position x y z and the players character
  521. #   to some predefined respawn point on the island. Used to position
  522. #   the island at the beginning of a part.
  523. #-------------------------------------------------------------------------------
  524. proc resetplayerat { x y z } {
  525.  
  526.     # find the player's towncenter
  527.     set userClan [/world.getuserclan]
  528.     if {$userClan != "null"} {
  529.  
  530.         # set player island to x,y,z
  531.         set playerIsland [$userClan.getplayerisland]
  532.         $playerIsland.setposition  $x $y $z
  533.         $playerIsland.setdirection 0 0 0
  534.  
  535.         # position maennel at towncenter
  536.         set player [$userClan.getmaennel]
  537.         
  538.         # reset handelt by world
  539.         /world.resetuserclan
  540.         
  541.         # some things must be done separatly
  542.         # war mal swim - bug beim drehen der playerisland   
  543.         $player.setstate stand
  544.         #input_stand                           
  545.  
  546.         # update the save point
  547.         savepoint
  548.     }
  549. }
  550.  
  551.  
  552. proc resetplayer {} {
  553.     resetplayerat 0 0 0
  554. }
  555.  
  556. #-------------------------------------------------------------------------------
  557. #   simpleresetat
  558. #
  559. #   Resets only most important things, world and Island.
  560. #   To use in levels with introcinematic, that place and animate
  561. #   the playercharacter via cinedummy so that the procedure doesn't affect
  562. #   players position.
  563. #-------------------------------------------------------------------------------
  564. proc simpleresetat {x y z} {
  565.  
  566.     # find the player's towncenter
  567.     set userClan [/world.getuserclan]
  568.     if {$userClan != "null"} {
  569.  
  570.         # set player island to x,y,z
  571.         set playerIsland [$userClan.getplayerisland]
  572.         $playerIsland.setposition  $x $y $z
  573.         $playerIsland.setdirection 0 0 0
  574.  
  575.         # position maennel at towncenter
  576.         # set player [$userClan.getmaennel]
  577.         
  578.         # reset handelt by world
  579.         /world.resetuserclan
  580.         
  581.         # some things must be done separatly
  582.         #$player.setstate swimming
  583.         #input_swimming                           
  584.  
  585.         # update the save point
  586.         savepoint
  587.     }
  588. }
  589.  
  590. #-------------------------------------------------------------------------------
  591. #   destroy symbolicName
  592. #
  593. #   Invoke ".reduceenergy 10000000" on all objects with a matching symbolic
  594. #   name.
  595. #-------------------------------------------------------------------------------
  596. proc killsymbol {symbolicName} {
  597.  
  598.     puts "-> destroy $symbolicName"
  599.  
  600.     set curObj ""
  601.     for {set curObj [/world.findobjectbysymbolicname $symbolicName]}\
  602.         {$curObj != "null"}\
  603.         {set curObj [/world.findnextobjectbysymbolicname $curObj $symbolicName]}\
  604.     {
  605.         #puts "destroy: $curObj"
  606.         $curObj.reduceenergy 10000000
  607.     }
  608.  
  609.     puts "<- destroy $symbolicName"
  610. }
  611.  
  612. #-------------------------------------------------------------------------------
  613. #   support method. searches for navpoint with specified symbolic name
  614. #-------------------------------------------------------------------------------
  615. proc getnavpoint {symbolicName} {
  616.  
  617.     set navPoint [/world.findobjectbysymbolicname $symbolicName]
  618.     if {$navPoint == "null"} {
  619.         return "null"
  620.     } else {
  621.         if {"false" == [$navPoint.isvehicleclass "abstract.navpoint"]} {
  622.             return "null"
  623.         } else {
  624.             return $navPoint
  625.         }
  626.     }
  627. }
  628.  
  629. #-------------------------------------------------------------------------------
  630. #   enableNavPoint symbolicName
  631. #
  632. #   tries to find Navpoint with symbolic name and enables it. Stops if navpoint
  633. #   does not exist or "symbolicName" is no navpoint. Allows multiple enable calls
  634. #
  635. #   04-Apr-02   floh    notify feedback handler 
  636. #-------------------------------------------------------------------------------
  637. proc enablenavpoint {symbolicName} {
  638.     set navPoint [getnavpoint $symbolicName]
  639.     
  640.     if {$navPoint != "null"} {
  641.         $navPoint.enable
  642.         /game/handler/feedback.registernavpointenabled        
  643.     } else {
  644.         puts "***** NAVPOINT $symbolicName EXISTIERT NICHT ********"
  645.     }
  646. }
  647.  
  648. proc enablenavpoint_mute {symbolicName} {
  649.     set navPoint [getnavpoint $symbolicName]
  650.     
  651.     if {$navPoint != "null"} {
  652.         $navPoint.enable
  653.     } else {
  654.         puts "***** NAVPOINT $symbolicName EXISTIERT NICHT ********"
  655.     }
  656. }
  657.  
  658. proc enablenavpointafter {time symbolicName} {
  659.     set action "enablenavpoint $symbolicName"
  660.     oneshotaction $time  $action
  661. }
  662.  
  663. proc enablenavpointafter_mute {time symbolicName} {
  664.     set action "enablenavpoint_mute $symbolicName"
  665.     oneshotaction $time  $action
  666. }
  667.  
  668. #-------------------------------------------------------------------------------
  669. #   disableNavPoint symbolicName
  670. #
  671. #   tries to find Navpoint with symbolic name and disables it. Stops if navpoint
  672. #   does not exist or "symbolicName" is no navpoint. Allows multiple enable calls
  673. #-------------------------------------------------------------------------------
  674. proc disablenavpoint {symbolicName} {
  675.  
  676.     set navPoint [getnavpoint $symbolicName]
  677.     set station [[/world.getuserclan].getplayerisland]
  678.     set targetNavPoint [$station.getislandtarget]
  679.     if {$navPoint != "null"} {
  680.         if {$navPoint == $targetNavPoint} {  
  681.             $station.setislandtarget "null"
  682.         }
  683.         $navPoint.disable
  684.     } else {
  685.         puts "***** NAVPOINT $symbolicName EXISTIERT NICHT ********"
  686.     }
  687. }
  688.  
  689. #-------------------------------------------------------------------------------
  690. #   playerhasitem symbolicName
  691. #
  692. #   Seeks the whole inventory to find symbolicName
  693. #-------------------------------------------------------------------------------
  694. proc playerhasitem {symbolicName} {
  695.  
  696.     puts "-> playerhasitem $symbolicName"
  697.  
  698.     set clan     [/world.getuserclan]
  699.     set maennel  [$clan.getmaennel]
  700.     set itemlist [$maennel.artefactlist]
  701.     set result   "false"
  702.     
  703.     foreach curItem $itemlist {
  704.         set curItemsymbolicName [$curItem.getsymbolicname]
  705.         
  706.         if { [string match $symbolicName $curItemsymbolicName] } {
  707.             set result "true"
  708.             break
  709.         }
  710.     }
  711.  
  712.     puts "<- playerhasitem $symbolicName $result"
  713.     return $result
  714. }
  715.  
  716. #-------------------------------------------------------------------------------
  717. #   removeplayeritem symbolicName
  718. #
  719. #   Seeks the whole inventory to find symbolicName and remove it
  720. #-------------------------------------------------------------------------------
  721. proc removeplayeritem {symbolicName} {
  722.  
  723.     puts "-> removeplayeritem $symbolicName"
  724.  
  725.     set clan     [/world.getuserclan]
  726.     set maennel  [$clan.getmaennel]
  727.     set itemlist [$maennel.artefactlist]
  728.     set result   "false"
  729.     
  730.     foreach curItem $itemlist {
  731.         set curItemsymbolicName [$curItem.getsymbolicname]
  732.         
  733.         if { [string match $symbolicName $curItemsymbolicName] } {
  734.             $clan.releasevehicle $curItem
  735.             set result "true"
  736.             break
  737.         }
  738.     }
  739.  
  740.     puts "<- playerhasitem $symbolicName $result"
  741.     return $result
  742. }
  743.  
  744. #-------------------------------------------------------------------------------
  745. #   removeplayeritemandslot symbolicName
  746. #
  747. #   Remove an artefact from the belt, release it (via removeplayeritem),
  748. #   and if the operation was successful, reduce number of belt slots by one.
  749. #-------------------------------------------------------------------------------
  750. proc removeplayeritemandslot {symbolicName} {
  751.  
  752.     puts "-> removeplayeritemandslot $symbolicName"
  753.  
  754.     set result [removeplayeritem $symbolicName]
  755.     if {$result == "true"} {
  756.         set maennel [[/world.getuserclan].getmaennel]
  757.         set curMaxArtefacts [$maennel.getmaxartefacts]
  758.         if {$curMaxArtefacts > 1} {
  759.             incr curMaxArtefacts -1
  760.             $maennel.setmaxartefacts $curMaxArtefacts
  761.         }
  762.     }
  763. }
  764.  
  765. #-------------------------------------------------------------------------------
  766. #   countbysymbolicname symbolicName
  767. #
  768. #   Counts Objects with Symbolic Name
  769. #-------------------------------------------------------------------------------
  770. proc countbysymbolicname {symbolicName} {
  771.  
  772.     puts "-> countbysymbolicname $symbolicName"
  773.  
  774.     set clan     [/world.getuserclan]
  775.     set maennel  [$clan.getmaennel]
  776.     set result   "0"
  777.  
  778.     set curObj ""
  779.     for {set curObj [/world.findobjectbysymbolicname $symbolicName]}\
  780.         {$curObj != "null"}\
  781.         {set curObj [/world.findnextobjectbysymbolicname $curObj $symbolicName]}\
  782.     {
  783.         incr result 1
  784.     }
  785.  
  786.     puts "<- countbysymbolicname $symbolicName $result"
  787.  
  788.     return $result
  789. }
  790.  
  791. #-------------------------------------------------------------------------------
  792. #   setclanenergyzero symbolicName
  793. #
  794. #   Set Clan with symbolicName Energy to Zero
  795. #-------------------------------------------------------------------------------
  796. proc setclanenergyzero {symbolicName} {
  797.     
  798.     puts "-> setclanenergyzero $symbolicName"
  799.        
  800.     for {set curObj [/world.findclanbysymbolicname  $symbolicName]}\
  801.         {$curObj != "null"}\
  802.         {set curObj [/world.findnextclanbysymbolicname $curObj $symbolicName]}\
  803.     {
  804.          $curObj.setcurrentenergy 0
  805.     }
  806.  
  807.     puts "<- setclanenergyzero $symbolicName"
  808. }
  809.  
  810. #-------------------------------------------------------------------------------
  811. #   maennelcanfly [true|false]
  812. #
  813. #   Turn flying ability of maennel on/off.
  814. #-------------------------------------------------------------------------------
  815. proc maennelcanfly {flag} {
  816.  
  817.     puts "-> maennelcanfly $flag"
  818.  
  819.     # get the user maennel
  820.     set userClan [/world.getuserclan]
  821.     set maennel [$userClan.getmaennel]
  822.     $maennel.setcanfly $flag
  823.  
  824.     if {"true" == $flag} {
  825.         # report to feedback handler
  826.         # wird vom boosterartefakt selbst gefeuert
  827.         # /game/handler/feedback.registermaennelcanfly
  828.     }
  829. }
  830.  
  831. #-------------------------------------------------------------------------------
  832. #   givetask symbolicName task parameter
  833. #
  834. #   universelles settask fuer ein Objekt
  835. #   symbolicName            wer soll das machen (z.B. "mueller")
  836. #   task                    was soll er machen (z.B. "attack")
  837. #   parameter               was soll er bearbeiten (z.B. "meier")
  838. #
  839. #   27-Feb-02   floh    + all objects which match the symbolic name get the task
  840. #                       + no longer causes game to quit when no matching object
  841. #                         exists
  842. #-------------------------------------------------------------------------------
  843. proc givetask {symbolicName task parameter} {
  844.  
  845. puts "*** givetask $symbolicName $task $parameter"
  846.     set curObj ""
  847.     for {set curObj [/world.findobjectbysymbolicname $symbolicName]}\
  848.         {$curObj != "null"}\
  849.         {set curObj [/world.findnextobjectbysymbolicname $curObj $symbolicName]}\
  850.     {
  851.         if {[$curObj.isvehicleclass "concret.technical.static.building.flakbuilding"] == "true"} {
  852.             set curObjproduct [$curObj.getproduct 0]
  853.             if {$curObjproduct != "null"} {
  854.                 $curObjproduct.settask $task $parameter
  855.                 puts "ist eine flak $task $parameter und gibt befehl an turret $curObjproduct"
  856.             }
  857.         } elseif {[$curObj.isvehicleclass "concret.technical.static.building.garage"] == "true"} {
  858.             set curObjproduct [$curObj.getproduct 0]
  859.             if {$curObjproduct != "null"} {
  860.                 $curObjproduct.settask $task $parameter
  861.                 puts "ist eine garage mit $task $parameter und gibt befehl an flieger $curObjproduct"
  862.             }
  863.         }
  864.         $curObj.settask $task $parameter
  865.         puts "--- task $task given to object $curObj"
  866.     }
  867. }
  868.  
  869. #-------------------------------------------------------------------------------
  870. #   killafter time symbolicname
  871. #
  872. #   Fa▀t den hΣufig gebrauchten Zusammenhang, da▀ etwas nach einer bestimmten
  873. #   Zeit gekillt werden soll zusammen
  874. #   (eventname ist nur aus Kompatibilaetsgruenden noch da)
  875. #-------------------------------------------------------------------------------
  876. proc killafter {time symbolicname {eventname "meier"}} {
  877.  
  878.     set action "killsymbol $symbolicname"
  879.     oneshotaction $time  $action
  880. }
  881.  
  882. #-------------------------------------------------------------------------------
  883. #   loadafter time encountername
  884. #
  885. #   Fa▀t den hΣufig gebrauchten Zusammenhang, da▀ etwas nach einer bestimmten
  886. #   Zeit geladen werden soll zusammen (encounter)
  887. #-------------------------------------------------------------------------------
  888. proc loadafter {time encountername {eventname "mueller"}} {
  889.  
  890.     set action "loadencounter $encountername"
  891.     oneshotaction $time  $action
  892. }
  893.  
  894. #-------------------------------------------------------------------------------
  895. #   islandmoveto navpointname
  896. #
  897. #   02-Apr-02   floh    Bugfix: hat nicht den Fall abgehandelt, dass es
  898. #                       den Navpoint ueberhaupt nicht gibt!
  899. #   29-Jul-02   floh    hat auch funktioniert, wenn ueberhaupt kein Navtower
  900. #                       aufgebaut war
  901. #-------------------------------------------------------------------------------
  902.  
  903. proc islandmoveto {navpointname} {
  904.  
  905.     set target [/world.findobjectbysymbolicname $navpointname]
  906.     set userClan [/world.getuserclan]
  907.     if {($target != "null") && ($userClan != "null")} {
  908.         set station [$userClan.getplayerisland]
  909.         if {$station != "null"} {
  910.             enablenavpoint_mute $navpointname
  911.             $station.setislandtarget $target
  912.  
  913.             # check if there is any navtower in house state in the user clan
  914.             set hasValidNavTower 0
  915.             for {set curObj [$userClan.gethead]} {$curObj != "null"} {set curObj [$curObj.getsucc]} {
  916.                 if {[$curObj.isvehicleclass "concret.technical.static.building.islanddrive"]} {
  917.                     if {[$curObj.getstate] == "house"} {
  918.                         set hasValidNavTower 1
  919.                     }
  920.                 }
  921.             }
  922.         }
  923.  
  924.         if {$hasValidNavTower} {
  925.             $station.setislanddriveworking true
  926.         }
  927.  
  928.     } else {
  929.         puts "*** NAVPOINT $navpointname EXISTIERT NICHT IN ROUTINE islandmoveto!!!"
  930.     }
  931. }
  932.  
  933. #-------------------------------------------------------------------------------
  934. #   setvar name value
  935. #
  936. #   Setzt eine Cookie-Variable auf einen Wert. Cookies bleiben waehrend des
  937. #   gesamten Spiels erhalten (auf ueber Part- und Chapter-Grenzen hinweg)
  938. #   und werden bei Savegames mit abgespeichert und geladen.
  939. #-------------------------------------------------------------------------------
  940. proc setvar {name value} {
  941.     /game/handler/cookie.setcookie $name $value
  942. }
  943.  
  944. #-------------------------------------------------------------------------------
  945. #   getvar name value
  946. #
  947. #   Fragt den Wert einer Cookie-Variablen ab. Falls die Cookie Variable nicht
  948. #   existiert wird ein ":null:" String zurueckgegeben.
  949. #-------------------------------------------------------------------------------
  950. proc getvar {name} {
  951.     return [/game/handler/cookie.getcookie $name]
  952. }
  953.  
  954. #-------------------------------------------------------------------------------
  955. #   clearvar name
  956. #
  957. #   Markiert eine Variable als temporaer, so dass sie am Ende eines Parts 
  958. #   automatisch geloescht wird
  959. #-------------------------------------------------------------------------------
  960. proc clearvar {name} {
  961.     /game/handler/cookie.marktemporary $name
  962. }
  963.  
  964. #-------------------------------------------------------------------------------
  965. #   existsvar name
  966. #
  967. #   Gibt "true" zurueck falls die Cookie-Variable existiert, andernfalls
  968. #   "false".
  969. #-------------------------------------------------------------------------------
  970. proc existsvar {name} {
  971.     return [/game/handler/cookie.cookieexists $name]
  972. }
  973.  
  974. #-------------------------------------------------------------------------------
  975. #   wind stΣrke
  976. #
  977. #    Stellt die WindstΣrke ein...
  978. #-------------------------------------------------------------------------------
  979. proc wind {strength} {
  980.     /sys/servers/channel.setchannel1f windstrength $strength
  981.     return
  982. }
  983.  
  984. #-------------------------------------------------------------------------------
  985. #   savepoint
  986. #   Speichert Spiel in speziellen savepoint.n Save-Slot ab.
  987. #-------------------------------------------------------------------------------
  988. proc savepoint {} {
  989.     /world.announcesavepoint "home:save/savepoint"
  990. }
  991.  
  992. #-------------------------------------------------------------------------------
  993. #   loadsavepoint
  994. #   Lade den aktuellen Save-Point.
  995. #-------------------------------------------------------------------------------
  996. proc loadsavepoint {} {
  997.     /world.announceloadsavepoint "home:save/savepoint.n"
  998. }
  999.  
  1000. #-------------------------------------------------------------------------------
  1001. #   restartlevel
  1002. #   Startet den aktuellen Part neu
  1003. #-------------------------------------------------------------------------------
  1004. proc restartlevel {} {
  1005.     puts "*** RESTART LEVEL"
  1006.  
  1007.     set path [/sys/servers/file.manglepath "home:save"]
  1008.     if {[file exists $path/restartpoint.n]} {
  1009.         /world.loadgame $path/restartpoint.n
  1010.     }
  1011. }
  1012.  
  1013. #-------------------------------------------------------------------------------
  1014. #   playanimation symbolicName 
  1015. #
  1016. #  symbolicname der jeweiligen cinematic oder des CINdummy
  1017. #   
  1018. #-------------------------------------------------------------------------------
  1019. proc playanimation {symbolicName} {
  1020.     puts "-> animate CINEMATICDUMMY: $symbolicName"
  1021.  
  1022.     # find cinedummy object
  1023.     set cineDummy [/world.findobjectbysymbolicname $symbolicName]
  1024.     if {$cineDummy != "null"} {
  1025.         
  1026.         puts "-> cinematic TARGET OBJECT: [$cineDummy.gettargetsymbolicname]"
  1027.  
  1028.         # find target object
  1029.         set cineTargetSymbolic [$cineDummy.gettargetsymbolicname]
  1030.         set cineSequence [$cineDummy.getcinematicsequencename]
  1031.         set cineTarget [/world.findobjectbysymbolicname $cineTargetSymbolic]
  1032.         if {$cineTarget != "null"} {
  1033.  
  1034.             set cineTargetState [$cineTarget.getstate]
  1035.             set action ""
  1036.             
  1037.             if {$cineTargetState == "explode"} {
  1038.  
  1039.                 # target is exploding: ignore
  1040.                 return
  1041.  
  1042.             } else {
  1043.                 # normal case:
  1044.                 set action "$cineTarget.setcinematicsequence $cineSequence; $cineTarget.setstate cinematic"
  1045.             }
  1046.             oneshotaction 0.01 $action
  1047.         }
  1048.     } else {
  1049.         puts " ! WARNUNG ! - cinematicDUMMY nicht gefunden (symbolicName = $symbolicName)!!!"
  1050.     }
  1051. }
  1052.  
  1053. #-------------------------------------------------------------------------------
  1054. #   playanimationafter time symbolicName 
  1055. #-------------------------------------------------------------------------------
  1056. proc playanimationafter {time symbolicName} {
  1057.     set action "playanimation $symbolicName"
  1058.     oneshotaction $time $action
  1059. }
  1060.  
  1061. #-------------------------------------------------------------------------------
  1062. #   stopanimation symbolicName 
  1063. #
  1064. #  symbolicname - der jeweiligen cinematic oder des cinematicdummys 
  1065. #  ( der ja targetsymbolicname hat)
  1066. #-------------------------------------------------------------------------------
  1067. proc stopanimation {symbolicName} {
  1068.     puts "-> STOP animattion CINEMATICDUMMY: $symbolicName"
  1069.     set pos [/world.findobjectbysymbolicname $symbolicName]
  1070.     if {$pos != "null"} {
  1071.         puts "-> cinematic OBJECT: [$pos.gettargetsymbolicname] : STOP"
  1072.         $pos.announcestate "normal"
  1073.     } else {
  1074.         puts " ! WARNUNG ! - cinematicDUMMY nicht gefunden !!!"
  1075.     }
  1076. }
  1077.  
  1078. #-------------------------------------------------------------------------------
  1079. #   playsound fileName
  1080. #
  1081. #   Play a high priority oneshot wav file.
  1082. #   Example:
  1083. #
  1084. #   playsound lib:sound/wolkentanz.wav
  1085. #-------------------------------------------------------------------------------
  1086. proc playsound {filename} {
  1087.     set action "/world.playsound $filename "
  1088.     oneshotaction 0.01 $action
  1089. }
  1090.  
  1091. #-------------------------------------------------------------------------------
  1092. #   playfeedbacksound fileName
  1093. #
  1094. #   Das playsound ist ja jetzt komplexer, wg oneshotaction -> also
  1095. #   gibt es jetzt noch ein einfacheres playfeedbacksound, welches wie frueher
  1096. #   funktioniert.
  1097. #-------------------------------------------------------------------------------
  1098. proc playfeedbacksound {filename} {
  1099.     /world.playsound $filename
  1100. }
  1101.  
  1102. #-------------------------------------------------------------------------------
  1103. #   findsymbol {symbolicName}
  1104. #
  1105. #   sucht object nach symbolicname und wenn nicht vorhanden meldung 
  1106. #   
  1107. #-------------------------------------------------------------------------------
  1108. proc findsymbol {symbolicName} {
  1109.     set pos [/world.findobjectbysymbolicname $symbolicName]
  1110.     if {$pos != "null"} {
  1111.         puts "position von: $symbolicName -> $pos"
  1112.         return $pos
  1113.     } else {
  1114.         puts " ! WARNUNG ! $symbolicName NICHT gefunden !!!"
  1115.     }
  1116. }
  1117.  
  1118. #-------------------------------------------------------------------------------
  1119. #   findclan {symbolicName}
  1120. #
  1121. #   sucht clan nach symbolicname und wenn nicht vorhanden meldung 
  1122. #   
  1123. #-------------------------------------------------------------------------------
  1124. proc findclan {symbolicName} {
  1125.     set pos [/world.findclanbysymbolicname $symbolicName]
  1126.     if {$pos != "null"} {
  1127.         puts "position von: $symbolicName -> $pos"
  1128.         return $pos
  1129.     } else {
  1130.         puts " ! WARNUNG ! $symbolicName NICHT gefunden !!!"
  1131.     }
  1132. }
  1133.  
  1134. #-------------------------------------------------------------------------------
  1135. #   switchoffnav {symbolicName} {symbolicName}
  1136. #
  1137. #   von den zwei ⁿbergebenen navpoints wird der nicht angefahrene disabled 
  1138. #   
  1139. #-------------------------------------------------------------------------------
  1140. proc switchoffnav {nav1Name nav2Name} {
  1141.     set nav1pos [/world.findobjectbysymbolicname $nav1Name]
  1142.     set nav2pos [/world.findobjectbysymbolicname $nav2Name]
  1143.     if { ($nav1pos != "null") &&  ($nav2pos != "null") } {
  1144.         set station [[/world.getuserclan].getplayerisland]
  1145.         set ziel [$station.getislandtarget]
  1146.         set zielsymbolicName [$ziel.getsymbolicname]
  1147.         if {$zielsymbolicName == $nav1Name} {
  1148.             puts "ziel: $nav1Name -> ausgeschalten: $nav2Name"
  1149.             disablenavpoint $nav2Name
  1150.         }
  1151.         if {$zielsymbolicName == $nav2Name} {
  1152.             puts "ziel: $nav2Name -> ausgeschalten: $nav1Name"
  1153.             disablenavpoint $nav1Name
  1154.         }
  1155.     } else {
  1156.         puts " ! WARNUNG ! $symbolicName NICHT gefunden !!!"
  1157.     }
  1158. }
  1159.  
  1160. #-------------------------------------------------------------------------------
  1161. #   Zeug zum an- und abschalten von Emittern
  1162. #-------------------------------------------------------------------------------
  1163. proc toggleemitter {symName onoff} {
  1164.     set obj ""
  1165.     set found 0
  1166.     for {set obj [/world.findobjectbysymbolicname $symName]}\
  1167.          {$obj != "null"}\
  1168.          {set obj [/world.findnextobjectbysymbolicname $obj $symName]} {
  1169.  
  1170.         set found 1
  1171.         $obj.enableemitting $onoff
  1172.     }
  1173.  
  1174.     if {$found == "0"} { 
  1175.         puts " ! WARNUNG ! $symName NICHT gefunden !!!"
  1176.     }
  1177. }
  1178.  
  1179. proc enableemitter {symName} {
  1180.     toggleemitter $symName true
  1181. }
  1182.  
  1183. proc disableemitter {symName} {
  1184.     toggleemitter $symName false
  1185. }
  1186.  
  1187. #-------------------------------------------------------------------------------
  1188. #   Game over erzwingen
  1189. #-------------------------------------------------------------------------------
  1190. proc forcegameover {} {
  1191. #    /world.unsethandcontrol
  1192. #    /sys/servers/menuhandler.openmenu ingame_endgame
  1193.  
  1194.     # kill maennel
  1195.     set userClan [/world.getuserclan]
  1196.     if {$userClan != "null"} {    
  1197.         set maennel [$userClan.getmaennel]
  1198.         if {$maennel != "null"} {
  1199.             $maennel.reduceenergy 10000000
  1200.         }
  1201.     }
  1202. }
  1203.  
  1204. #-------------------------------------------------------------------------------
  1205. #   Zeug zum an- und abschalten von Fabriken
  1206. #-------------------------------------------------------------------------------
  1207. proc togglefactory {symName onoff} {
  1208.     set obj [/world.findobjectbysymbolicname $symName]
  1209.     if {$obj == "null"} {
  1210.         puts " ! WARNUNG ! $symName NICHT gefunden !!!"
  1211.         return
  1212.     }
  1213.     $obj.setsleepmode $onoff
  1214. }
  1215.  
  1216. proc enablefactory {symName} {
  1217.     togglefactory $symName false
  1218. }
  1219.  
  1220. proc disablefactory {symName} {
  1221.     togglefactory $symName true
  1222. }
  1223.  
  1224. #-------------------------------------------------------------------------------
  1225. #   zum entfernen von objekten aus der szene 
  1226. #-------------------------------------------------------------------------------
  1227. proc releasesymbol {symbolicName} {
  1228.     set obj [/world.findobjectbysymbolicname $symbolicName]
  1229.     if {$obj != "null"} {
  1230.         $obj.setremoveable true
  1231.         set objclan [$obj.getclan]
  1232.         $objclan.releasevehicle $obj  
  1233.     } else {
  1234.         puts " ! WARNUNG ! $symbolicName NICHT gefunden !!!"
  1235.     }
  1236. }
  1237.  
  1238. proc release_clan {symbolicName} {
  1239.     set obj [/world.findclanbysymbolicname $symbolicName]
  1240.     if {$obj != "null"} {
  1241.         /world.releaseclan $obj
  1242.     } else {
  1243.         puts " ! WARNUNG ! $symbolicName NICHT gefunden !!!"
  1244.     }
  1245. }
  1246. #-------------------------------------------------------------------------------
  1247. #   zum entfernen von objekten aus der szene nach bestimmter zeit
  1248. #-------------------------------------------------------------------------------
  1249. proc releaseafter {time symbolicname {eventname "meier"}} {
  1250.     set action "releasesymbol $symbolicname"
  1251.     oneshotaction $time $action
  1252. }
  1253.  
  1254. #-------------------------------------------------------------------------------
  1255. #   artefact kann an bestimmten buildslot-Typ(1,2,3,4) gekoppelt werden
  1256. #   dh. das bauen ist dann auf diesem slot m÷glich
  1257. #-------------------------------------------------------------------------------
  1258. proc artefactmod {symbolicname buildslottyp} {
  1259.     set obj [/world.findobjectbysymbolicname $symbolicname]
  1260.     if {$obj != "null"} {
  1261.         set war [$obj.getbuildingclass]
  1262.         $obj.setbuildingclass $buildslottyp
  1263.         puts "TYPSWITCH FROM: $war TO: $buildslottyp"
  1264.     } else {
  1265.         puts " ! WARNUNG ! $symbolicName NICHT gefunden !!!"
  1266.     }
  1267. }
  1268.  
  1269. #-------------------------------------------------------------------------------
  1270. #   setplayerpos xPos yPos zPos yAngle
  1271. #
  1272. #   Saubere Maennel-Positionierungs-Routine, initialisiert Position/Blickrichtung,
  1273. #   setzt Speed auf 0 und koppelt evtl. von Insel ab.
  1274. #-------------------------------------------------------------------------------
  1275. proc setplayerpos {xPos yPos zPos yAngle} {
  1276.     set userClan [/world.getuserclan]
  1277.     if {$userClan != "null"} {
  1278.  
  1279.         # position maennel at towncenter
  1280.         set player [$userClan.getmaennel]
  1281.         $player.unlinkfromstation
  1282.         $player.setposition $xPos $yPos $zPos
  1283.         $player.setdirection 0 $yAngle 0
  1284.         $player.setspeed 0 0 0
  1285.         
  1286.         # reset collision system to flush preMove-Position
  1287.         #set curState [$player.getstate]
  1288.         #$player.setstate $curState
  1289.         $player.setstate "stand"
  1290.     }
  1291. }
  1292.  
  1293. #-------------------------------------------------------------------------------
  1294. #   missionobjective fileName (ohne Pfad)
  1295. #
  1296. #   Setzt den Namen der Bitmap, die als Mission Objective angezeigt wird
  1297. #   
  1298. #-------------------------------------------------------------------------------
  1299. proc missionobjective {name} {
  1300.     /game/handler/cookie.setcookie __objective $name
  1301. }
  1302.    
  1303. #-------------------------------------------------------------------------------
  1304. #   textmessage name
  1305. #
  1306. #   Setzt den Namen der Message, die angezeigt werden soll
  1307. #   
  1308. #-------------------------------------------------------------------------------
  1309. proc textmessage {name} {
  1310.     /sys/servers/menuhandler.showtextmessage "book:feedback/if_$name.bmp"
  1311. #-------------------------------------------------------------------------------
  1312. #   time display
  1313. #   
  1314. #-------------------------------------------------------------------------------
  1315. proc timer_display {time} {
  1316.     if { $time == 10 } {
  1317.         textmessage noch10sec
  1318.     }
  1319.     if { $time == 30 } {
  1320.         textmessage noch30sec
  1321.         set time 10
  1322.         oneshotaction 20 "timer_display $time"
  1323.     }
  1324.     if { $time == 1 } {
  1325.         textmessage noch01min
  1326.         set time 30
  1327.         oneshotaction 30 "timer_display $time"
  1328.     }
  1329.     if { $time == 2 } {
  1330.         textmessage noch02min
  1331.     }
  1332.     if { $time == 3 } {
  1333.         textmessage noch03min
  1334.     }
  1335.     if { $time == 4 } {
  1336.         textmessage noch04min
  1337.     }
  1338.     if { $time == 5 } {
  1339.         textmessage noch05min
  1340.     }
  1341.     if { $time == 6 } {
  1342.         textmessage noch06min
  1343.     }
  1344.     if { $time == 7 } {
  1345.         textmessage noch07min
  1346.     }
  1347.     if { $time == 8 } {
  1348.         textmessage noch08min
  1349.     }
  1350.     
  1351.     if { $time < 10 } {
  1352.        set time [expr $time-1]
  1353.        oneshotaction 60 "timer_display $time"
  1354.     }
  1355.  
  1356. #-------------------------------------------------------------------------------
  1357. # Enter Vehicle. 
  1358. #-------------------------------------------------------------------------------
  1359. proc entervehicle {who} {
  1360.  
  1361.     if {"null" == $who} {
  1362.         return
  1363.     }
  1364.     
  1365.     /world.sethandcontrol $who
  1366.     /world.setviewercarrier $who
  1367.     #input_possessingvehicle
  1368.     set userClan [/world.getuserclan]
  1369.     if {"null" != $userClan} {
  1370.         set maennel [$userClan.getmaennel]
  1371.         if {"null" != $maennel} {
  1372.             $maennel.setpossessingvehicle true
  1373.         }
  1374.     }
  1375. }
  1376.  
  1377. #-------------------------------------------------------------------------------
  1378. #   friendname
  1379. #
  1380. #   Liefert den Namen des Charakters, den der Spieler gewaehlt hat
  1381. #   (char_john, char_goliath oder char_susie
  1382. #   
  1383. #-------------------------------------------------------------------------------
  1384. proc friendname {} {
  1385.     set name [/game/handler/cookie.getcookie "_character"]
  1386.     return $name
  1387. }
  1388.  
  1389. #-------------------------------------------------------------------------------
  1390. #   countplayerflaks 
  1391. #
  1392. #   Liefert die anzahl der gebauten playerflaks zurueck
  1393. #   
  1394. #-------------------------------------------------------------------------------
  1395. proc countplayerflaks {} {
  1396.     set result 0
  1397.     for {set curObj [/world.findobjectbysymbolicname "playerflak"]}\
  1398.     {$curObj != "null"}\
  1399.     {set curObj [/world.findnextobjectbysymbolicname $curObj "playerflak"]}\
  1400.     {
  1401.         if { [$curObj.getartefactmode] == "false" } {
  1402.             incr result 1   
  1403.         }
  1404.     }
  1405.     puts "Anzahl gebauter FLAKS: $result"
  1406.     return $result
  1407. }
  1408.  
  1409. #-------------------------------------------------------------------------------
  1410. #   playerclanhasitem 
  1411. #
  1412. #   liefert "true" bzw "false" zurⁿck - checken der playerclans
  1413. #   
  1414. #-------------------------------------------------------------------------------
  1415. proc playerclanhasitem {symbolicName} {
  1416.  
  1417.     set clan [/world.getuserclan]
  1418.     set result   "false"
  1419.     
  1420.     for {set v [$clan.gethead]} {$v != "null"} {set v [$v.getsucc]} {
  1421.         if { [$v.getsymbolicname] == $symbolicName } {
  1422.             set result "true"
  1423.             break   
  1424.             puts "im clan"
  1425.         }
  1426.     }
  1427.     return $result
  1428. }
  1429.  
  1430. #-------------------------------------------------------------------------------
  1431. #   EOF
  1432. #-------------------------------------------------------------------------------
  1433.